#ifndef __GAMEOBJECTMANAGER_H__
#define __GAMEOBJECTMANAGER_H__

#include "stdafx.h"
#include "Objects/ObjectLists/GameObjectListInterface.h"
#include "Objects/ObjectLists/GameObjectList.h"
#include "Objects/GameObject.h"
#include "Box2D.h"
#include "Render.h"

class GameObjectManager
{
public:
	GameObjectManager(void);
	~GameObjectManager(void);

	GameObject* GetNewObject( const char* name);
	GameObject* Spawn( const char* name);
	void SaveData(CWriteFile* stream);
	void LoadData(CReadFile* stream);

	#define MAX_NUM_GAME_OBJECTS 512
	GameObjectListInterface& GetGameObjects(){return m_gameObjects;};
	#define MAX_NUM_FARRANGE_OBJECTS 512
	GameObjectListInterface& GetFarRangeObjects() { return m_farRangeObjects; }

	void InitializeGameObjects();
	void InitPhysics();
	b2World&        GetPhysicsWorld();

	void UpdateGameObjects();
	void             UpdatePhysics( float timestep );
	void UpdateGameObjectsStep1();
	void UpdateGameObjectsStep2();
	void UpdateGameObjectsStep3();

	void UpdateObjectAttributes(GameObject* obj);

	void DrawGameObjects();

	DebugDraw m_debugDraw;
protected:
	GameObjectList		m_gameObjects;

	GameObjectList		m_farRangeObjects;

	
private:
	b2World*           m_pBox2DWorld;
	b2ContactListener* m_physicsContactListener;
	b2ContactFilter*   m_physicsContactFilter;
	b2BoundaryListener* m_physicsBoundaryListener;
};
#endif